package com.gsit.omega.ea.domain;

import java.util.Calendar;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;

import com.gsit.omega.ea.utils.ProjectStatus;


@RooJavaBean
@RooToString
@RooEntity
public class Project {
	
	@NotNull
	private String code;

	@NotNull
	private String name;

	private String description;

	@NotNull
	@Temporal(TemporalType.TIMESTAMP)
	@DateTimeFormat(style = "M-")
	private Calendar startDate;

	@Temporal(TemporalType.TIMESTAMP)
	@DateTimeFormat(style = "M-")
	private Calendar endDate;
	
	
	@ManyToOne
	private Customer customer;
	
	@ManyToMany(cascade = CascadeType.ALL)
    private Set<MileStone> mileStones = new HashSet<MileStone>();
	
	 @Enumerated
	 private ProjectStatus status;
	 
	public String toString() {
	    StringBuilder sb = new StringBuilder();
	       sb.append("Code: ").append(getCode()).append(", ");
	       sb.append("Status: ").append(getStatus());
	     return sb.toString();
	}

}
